% Demonstrate some features of the dotsPlayble class family.
clear
clear classes
clc

% access the manager that deals with playable objects
dotsThePlayablesManager.reset('clientMode', false, 'serverMode', false);
pm = dotsThePlayablesManager.theObject;

% create an object to play a sinusoidal tone
tony = pm.newObject('dotsPlayableTone');
tony.frequency = 440;
tony.duration = 1;
tony.intensity = .25;

% play the tone
%   wait until the tone is done because playing happens "in the background"
tony.prepareToPlay;
pm.mayPlayPlayable(tony);
pause(tony.duration)

% alter the tone parameters and play it again
tony.frequency = 880;
tony.duration = 2;
tony.prepareToPlay;
pm.mayPlayPlayable(tony);
pause(tony.duration)

% create an object to play a sound from a file
%   the "Coin.wav" is included along with this demo script
filey = pm.newObject('dotsPlayableFile');
filey.fileName = 'Coin.wav';
filey.intensity = .1;

% play from the sound file
filey.prepareToPlay;
pm.mayPlayPlayable(filey);
pause(filey.duration)

% alter the sound file intensity and play it again
filey.intensity = 1;
filey.prepareToPlay;
pm.mayPlayPlayable(filey);
pause(filey.duration)

% try to play two sounds at once
pm.mayPlayPlayable(tony);
pause(tony.duration/2)
pm.mayPlayPlayable(filey);
pause(filey.duration)